/**
 * Book.java
 * Wraps an uploaded ebook file in a book data access object.
 */
package com.example.myproject;

import java.io.File;

public class BookUpload {
	
	public BookUpload(){}
	
	/**
	 * Uploads an ebook file to the blobstore.
	 * @param src The source ebook file to be uploaded.
	 * @param master 
	 * @return true if successfully uploaded, false if not.
	 */
	public boolean upload(File src, UploadDTO master)
	{
		
		try {
			
			BookUploadDTO book = new BookUploadDTO();
			BookUploadDAO dao = new BookUploadDAO();
			
			book.setTitle(master.getTitle());
			book.setCaption(master.getCaption());
			book.setContentType(master.getContentType());
			book.setPath(master.getPath());
			book.setParentId(master.getId());
			dao.save(book);
			return true;
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}
	
}
